<?php 

namespace App\Presenters;

use Laracasts\Presenter\Presenter;

class OrderPresenter extends Presenter
{
	protected $workerName = ['A'=>'designer', 'B'=>'programmer', 'C'=>'inputer'];

    public function worker()
    {
    	$workerName = $this->workerName;

    	if ($this->product == 2) {
    		unset($workerName['A']);
    	}

    	$data = [];
    	$name = '';

    	foreach ($workerName as $key => $value) {
    		$name   = $this->{$value} ? $this->{$value}->name : $key;
    		$data[] = "<span><code>{$name}</code></span>";
    	}

    	return join('', $data);
    }
}